﻿namespace Sunny.UI
{
    public class UITextBoxTreeView : UIDropDownItem
    {
        private UITreeView treeView;

        private void InitializeComponent()
        {
            this.treeView = new Sunny.UI.UITreeView();
            this.SuspendLayout();
            // 
            // treeView
            // 
            this.treeView.Dock = System.Windows.Forms.DockStyle.Fill;
            this.treeView.FillColor = System.Drawing.Color.White;
            this.treeView.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.treeView.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
            this.treeView.Location = new System.Drawing.Point(0, 0);
            this.treeView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
            this.treeView.MinimumSize = new System.Drawing.Size(1, 1);
            this.treeView.Name = "treeView";
            this.treeView.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
            this.treeView.ShowText = false;
            this.treeView.Size = new System.Drawing.Size(270, 234);
            this.treeView.TabIndex = 1;
            this.treeView.Text = "uiTreeView1";
            this.treeView.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
            this.treeView.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_NodeMouseClick);
            // 
            // UITextBoxTreeView
            // 
            this.Controls.Add(this.treeView);
            this.Name = "UITextBoxTreeView";
            this.Size = new System.Drawing.Size(270, 234);
            this.ResumeLayout(false);

        }

        public UITextBoxTreeView()
        {
            InitializeComponent();
        }

        public UITreeView TreeView => treeView;

        private void treeView_NodeMouseClick(object sender, System.Windows.Forms.TreeNodeMouseClickEventArgs e)
        {
            if (e.Location.X > treeView.DrawLeft(e.Node))
            {
                if (e.Node.Nodes.Count == 0)
                {
                    DoValueChanged(treeView, e);
                    Close();
                }
            }
        }
    }
}
